<?php
session_start();
if (!$_SESSION['tablename'])
    session_register('tablename');

$tablename = $_SESSION['tablename'];

include 'conn.php';
switch (strtolower($tablename)) {
    case 'ats_city':
        $city = $_REQUEST['city'];
        $sql = "insert into $tablename(city) values('$city')";
        break;
    default:
        $firstname = $_REQUEST['firstname'];
        $lastname = $_REQUEST['lastname'];
        $phone = $_REQUEST['phone'];
        $email = $_REQUEST['email'];

        $sql = "insert into users(firstname,lastname,phone,email) values('$firstname','$lastname','$phone','$email')";
        break;
}


$result = @mysql_query($sql);
if ($result) {
    echo json_encode(array('success' => true));
} else {
    echo json_encode(array('msg' => 'Some errors occured.'));
}
?>